<?php

namespace App\Controller;

use App\Logic;

class SurveyController extends AppBaseController
{
    private $surveyLogic;

    public function _initialize()
    {
        parent::_initialize();
        $this->surveyLogic = new Logic\SurveyLogic();
    }

    /**
     * 去问卷墙.
     *
     * @return void
     */
    public function goWall()
    {
        $userInfo = $this->getUserInfo();
        $userId = $userInfo['id'];

        $panelid = $this->surveyLogic->getPanelid();
        $crypt = $this->surveyLogic->getCrypt($userId);
        $attrRes = $this->surveyLogic->getAttrStr($userId);
        if (static::$res->isErr($attrRes)) {
            //去数据补充页面
            redirect(C('WEB_DOMAIN').'/User/editSurveyUser');
            exit;
        }
        $attr = $attrRes['Result'];

        $param = array(
            'panelid' => $panelid,
            'crypt' => $crypt,
            'attr' => $attr,
        );

        $url = C('SURVEY_WALL_URL').'?'.http_build_query($param);
        redirect($url);
    }

}
